import requests
from pathlib import Path


def download_html(filename, url):
    f = Path(filename)
    if not f.exists():
        response = requests.get(url)
        f.write_text(response.text)


def download_image(to_folder, url, filename):
    print(f'Start downloading {to_folder} -> {filename}: ', end='')
    Path(to_folder).mkdir(parents=True, exist_ok=True)
    f = Path(to_folder) / Path(filename)

    if f.exists():
        print('Already existed, skipped')
    else:
        r = requests.get(url)
        f.write_bytes(r.content)
        print('Done')
